package com.crack.nga2.utils;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Http请求时封装参数
 * Created by Administrator on 2015/12/16.
 */
public class HttpParams {

    private Map<String, String> map;

    public HttpParams() {
        map = new LinkedHashMap<>();
    }

    public void put(String key, String value) {
        map.put(key, value);
    }

    public void put(String key, int value){map.put(key,String.valueOf(value));}

    public void put(String key, boolean value){map.put(key,String.valueOf(value));}

    public Map<String,String> getMap(){
        return map;
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<String, String> entry : map.entrySet()) {
            sb.append(entry.getKey()).append("=").append(entry.getValue());
            sb.append("&");
        }
        sb.deleteCharAt(sb.length() - 1);
        return sb.toString();
    }

}
